<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
 * @OA\Schema(
 *     schema="WorkTicketImageResource",
 *     title="工单图片资源",
 *     description="工单图片信息",
 *     @OA\Property(property="id", type="integer", description="图片ID", example=1),
 *     @OA\Property(property="work_ticket_id", type="integer", description="工单ID", example=1),
 *     @OA\Property(property="work_ticket_detail_id", type="integer", description="工单详情ID", example=1),
 *     @OA\Property(property="path", type="string", description="图片路径", example="/uploads/tickets/image1.jpg"),
 *     @OA\Property(property="created_at", type="string", format="date-time", description="创建时间", example="2025-01-01 12:00:00"),
 *     @OA\Property(property="updated_at", type="string", format="date-time", description="更新时间", example="2025-01-01 12:00:00")
 * )
 * @mixin \App\Models\WorkTicketImage
 */
class WorkTicketImageResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'work_ticket_id' => $this->work_ticket_id,
            'work_ticket_detail_id' => $this->work_ticket_detail_id,
            'path' => $this->path,
            'created_at' => $this->created_at?->toDateTimeString(),
            'updated_at' => $this->updated_at?->toDateTimeString(),
        ];
    }
} 